package com.zhoug.speech.xunfei;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.iflytek.cloud.ErrorCode;
import com.iflytek.cloud.InitListener;

import androidx.annotation.Keep;

/**
 * 讯飞初始化接口
 * @Author 35574
 * @Date 2020/7/8
 * @Description
 */
@Keep
public class SpeechInitListener implements InitListener {
    private static final String TAG = ">>>SpeechInitListener";
    private Context mContext;

    public SpeechInitListener(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void onInit(int code) {
        if(code != ErrorCode.SUCCESS){
            Log.e(TAG, "onInit:科大讯飞语音识别初始化失败，错误码:" + code);
            toast("初始化失败，错误码：" + code+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
        }
    }

    private void toast(String msg){
        Toast.makeText(mContext.getApplicationContext(),msg,Toast.LENGTH_SHORT).show();
    }

}
